{% extends 'myadmin/base.html' %}

{% block main_body %}


<div style="height:60px">

</div>


  <section class="content">

      <div class="container-fluid">
        <div class="row">
          <div class="col-12">

    <div class="card">
              <div class="card-header">
                <h3 class="card-title"><a href="{% url 'myadmin_flavor_index' %}">首页</a> >> 实例类型管理</h3>
              </div>
              <div style="height:50px">
                <div style="width:120px;float:right;padding:10px;">
                   <button type="button" class="btn btn-block btn-primary" onclick="search()">浏览</button>
                </div>
               <div style="width:120px;float:right;padding:10px;">
                   <button type="button" class="btn btn-block btn-primary" onclick="add()">添加</button>
                </div>
                </div>

              <!-- /.card-header -->
              <div class="card-body">
                <table id="example2" class="table table-bordered table-hover">
                  <thead>
                  <tr>
                    <th>ID</th>
                    <th>实例类型名称</th>
                    <th>VCPU数量</th>
                      <th>内存</th>
                   <th>根磁盘</th>
                      <th>Swap磁盘</th>
                    <th>动作</th>
                  </tr>
                  </thead>
                  <tbody>
                  {% for flavor in flavorlist %}
                  <tr>
                    <td>{{ flavor.id }}</td>
                      <input type="hidden" id="flavorid" value="{{ flavor.id }}" />
                    <td>{{ flavor.name }}</td>
                    <td>{{ flavor.vcpus }}</td>
                    <td>{{ flavor.ram }}MB</td>
                    <td>
                        {{ flavor.disk}}GB
                    </td>
                      <td>{% if flavor.swap == "" %}
                         0GB
                        {% else %}
                        {{ flavor.swap }} MB
                        {% endif %}
                       </td>
                    <td><a href="{% url 'myadmin_flavor_edit' flavor.id  %}" />编辑</a>  |  <a onclick="delflavor()" style="cursor:pointer;" >删除</a> </td>
                  </tr>
                  {% endfor %}

                  </tfoot>
                </table>
              </div>
              <!-- /.card-body -->
            </div>
          </div>
        </div>
      </div>
  </section>


<script>
    function search() {
          window.location.href = "/myadmin/flavor/index";
    }
    function add() {
          window.location.href = "/myadmin/flavor/add";
    }
    function delflavor(){
        if(confirm('确实要删除此实例类型吗?')){
          id = document.getElementById('flavorid').value;
          //alert(uid);
          window.location.href = "/myadmin/flavor/delete/"+id;
        }
    }
 </script>




{% endblock %}